﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;
using LiftBill;
using System.Collections.ObjectModel;

namespace LiftManagement
{
    /// <summary>
    /// 清单管理
    /// </summary>
    public partial class FoodInventoryWin : Window
    {
        public FoodInventoryWin()
        {
            InitializeComponent();
            btn_OK.Click += new RoutedEventHandler(btn_OK_Click);
            btn_Delete.Click += new RoutedEventHandler(btn_Delete_Click);
            btn_Cancel.Click += new RoutedEventHandler(btn_Cancel_Click);
            this.Loaded += new RoutedEventHandler(FoodInventoryWin_Loaded);
        }

        void FoodInventoryWin_Loaded(object sender, RoutedEventArgs e)
        {
            InitializeUI();
        }

        private void InitializeUI()
        {
            if (FoodBaseList == null || FoodBaseList.Count == 0)
                return;
            lv_Data.CreateListViewDataBindColumns("Name", 200);
            lv_Data.DataItemSource = FoodBaseList;

        }

        void btn_Cancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        void btn_Delete_Click(object sender, RoutedEventArgs e)
        {

        }
        private FoodBase GetFood()
        {
            FoodBase foodbase = new FoodBase();
            foodbase.ID = Guid.NewGuid().ToString();
            foodbase.Name = txt_FoodName.Text.Trim();
            foodbase.Type = txt_FoodType.Text;
            return foodbase;
        }
        void btn_OK_Click(object sender, RoutedEventArgs e)
        {
            FoodBase foodBase = GetFood();
            FoodBaseList.Add(foodBase);
        }
        public ObservableCollection<FoodBase> FoodBaseList { get; set; }


    }
}
